package com.servlet;

import com.dao.logindao;
import com.dao.logindaoimpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class gregister extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf8");
        String id=req.getParameter("id");
        String pwd=req.getParameter("pwd");
        logindao r=new logindaoimpl();
        if(r.gregister(id,pwd))
        {
            req.getRequestDispatcher("gldenglu.jsp").forward(req,resp);
        }
        else
        {
            req.setAttribute("rmessage","该账号已被注册");
            req.getRequestDispatcher("/glzhuce.jsp").forward(req,resp);
        }

    }
}
